package com.at.bigdata.spark.core.acc

import org.apache.spark.{SparkConf, SparkContext}

/**
 * 依赖关系
 *
 * @author cdhuangchao3
 * @date 2023/3/6 8:40 PM
 */
object Spark01_Acc {

  def main(args: Array[String]): Unit = {
    val sparConf = new SparkConf().setMaster("local").setAppName("WordCount")
    val sc = new SparkContext(sparConf)

    val rdd = sc.makeRDD(List(1, 2, 3, 4))

//    val i = rdd.reduce(_ + _)
//    println(i)

    var sum = 0
    rdd.foreach(
      num => {
        sum += num
      }
    )
    println("sum=" + sum)

    sc.stop()
  }
}
